package com.ftg.learn.service.impl;

import com.ftg.learn.comm.entity.question.Type;
import com.ftg.learn.mapper.TypeMapper;
import com.ftg.learn.service.ITypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ftg.learn.util.ResBean;
import com.ftg.learn.util.tools.ConventUtil;
import com.ftg.learn.vo.TypeTreeVo;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 题目类别表 服务实现类
 * </p>
 *
 * @author kangjx
 * @since 2022-11-13
 */
@Service
public class TypeServiceImpl extends ServiceImpl<TypeMapper, Type> implements ITypeService {

    @Override
    public ResBean showTypeWithTree() {
        List<Type> list = this.baseMapper.selectList(null);
//        这个应该 是lombok的显示问题
        if(Objects.isNull(list)){
            return ResBean.noData();
        }
        List<TypeTreeVo> tree = ConventUtil.createTree(list,TypeTreeVo.class);
        return ResBean.success(tree);
    }



}
